package com.evan.common.core.constant;

public enum SubjectTypeEnum {
    SINGLE_SELECT(1, "单选题"),
    MULTI_SELECT(2, "多选题"),
    JUDGE(3, "判断题"),
    SURVEY(4, "评价打分"),
    TEXT(5, "文本"),
    FILL_IN(6, "填空题");

    private int code;
    private String name;

    SubjectTypeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static SubjectTypeEnum getByCode(int code) {
        for (SubjectTypeEnum subjectTypeEnum : values()) {
            if (subjectTypeEnum.getCode() == code) {
                return subjectTypeEnum;
            }
        }
        return null;
    }

    public static SubjectTypeEnum getByName(String name) {
        for (SubjectTypeEnum subjectTypeEnum : values()) {
            if (subjectTypeEnum.getName().equals(name)) {
                return subjectTypeEnum;
            }
        }
        return null;
    }
}
